/*
	This file is part of the OdinMS Maple Story Server
    Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
					   Matthias Butz <matze@odinms.de>
					   Jan Christian Meyer <vimes@odinms.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation version 3 as published by
    the Free Software Foundation. You may not use, modify or distribute
    this program under any other version of the GNU Affero General Public
    License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
-- Odin JavaScript --------------------------------------------------------------------------------
	Spinel Tour Guide - Multiple Place
-- By ---------------------------------------------------------------------------------------------
	Information
-- Version Info -----------------------------------------------------------------------------------
	1.0 - First Version by Information
---------------------------------------------------------------------------------------------------
**/

importPackage(net.sf.odinms.server.maps);
var status = 0;
var mapid = new Array(701000000, 800000000, 500000000);
var menuitem = new Array("Shanghai of China","Mushroom Shrine of Japan","Floating Market of Thailand");
var cost = new Array(3000, 3000, 3000);
var menu = "";
var section = 0;
var returnmap;
var jumper;
var pheader;
var i;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if((status == 0 || status == 1) && mode == 0) {
			cm.dispose();
			return;
		}
		if(mode == 0) {
			cm.sendOk("If you ever change your mind, please let me know.");
			cm.dispose();
			return;
		}
		if(mode == 1)
			status++;
		else
			status--;
		for(i=0; i < mapid.length; i++) {
			if(mapid[i] == cm.getChar().getMapId())
				section = 1;
		}
		
		if(status == 0) {
			if(section == 0) {
				cm.sendNext("If you're tired of the monotonous daily life, how about getting out for a change? There's nothing quite like soaking up a new culture, learning something new by the minute! It's time for you to get you and travel. We, at the Maple Travel Agency recommend you going on a #bWorld Tour#k! Are you worried about the travel expense? Need not worry! We, the #bMaple Trabel Agency#k have carefully come up with a plan to let you travel for ONLY #b3,000 mesos#k!");
			} else {
				returnmap = cm.getChar().getSavedLocation(SavedLocationType.WORLDTOUR);
				cm.sendSimple("How's the traveling? Are you enjoying it?\r\n#L0##bCan i go somewhere else?#k#l\r\n#L1##bI'm done with traveling. Can i go back to #m"+returnmap+"?##k#l");
			}
		} else if(status == 1) {
			if(section == 0) {
				cm.sendSimple("We offer these places for your traveling pleasure:\r\n#bShanghai of China,Mushroom Shrine of Japan and Floating Market of Thailand#k. Wherever you decided to travel, I'll be there serving you as the travel guide. Now, where would you like to head to?\r\n#L0##bShanghai (China)#k#l\r\n#L1##bMushroom Shrine (Japan)#k#l\r\n#L2##bFloating Market (Thailand)#k#l")
			} else {
				if(selection == 0){
					for(i=0; i < mapid.length; i++) {
						if(mapid[i] != cm.getChar().getMapId()) {
							menu += "\r\n#L"+i+"##b"+menuitem[i]+" (3,000 mesos)#k#l";
						}
					}
					cm.sendSimple("Where would you like to travel?"+menu);
				} else {
					cm.warp(returnmap);
					cm.dispose();
				}
			}
		} else if(status == 2) {
			jumper = selection;
			pheader = ("Would you like to travel to #b"+menuitem[jumper]+"#k?");
			if(section == 0) {
				if(jumper == 0) {
					cm.sendNext(pheader+" China is a country that is undergoing a rapid change towards modernism, and ro city clearly represents that as well as #bShanghai#k. First-time visitors of China may taken aback by a slew of modern buildings and squeaky-clean streets.");
				} else if(jumper == 1) {
					cm.sendNext(pheader+" If you desire to feel the essence of Japan, there's nothing like visiting the Shrine, a Japanese cultural melting pot. Mushroom Shrine is a mythical place that serves the incomparable Mushroom God from ancient times.");
				} else if(jumper == 2) {
					cm.sendNext(pheader+" Just like the name, Floating Market is a town located on the top of the river. This is a town that simultaneously features palm trees and historical features of Thailand.");
				}
			} else {
				status = 3;
				if(jumper == 0) {
					cm.sendYesNo(pheader+" To head over #m"+mapid[jumper]+"#, it'll cost you only #b3,000 mesos#k. Would you like to go right now?");
				} else if(jumper == 1) {
					cm.sendYesNo(pheader+" To head over #m"+mapid[jumper]+"#, it'll cost you only #b3,000 mesos#k. Would you like to go right now?");
				} else if(jumper == 2) {
					cm.sendYesNo(pheader+" To head over #m"+mapid[jumper]+"#, it'll cost you only #b3,000 mesos#k. Would you like to go right now?");
				} else {
					cm.sendOk("Please report this bug");
					cm.dispose();
				}
			}
		} else if (status == 3) {
				if(jumper == 0) {
					cm.sendNextPrev("Outside the city, however, lies the prototypical countryside, where nature rules modernism. More than anything, this represents the past and the present of China. Now, let's head over to #bShanghai#k, a city that embodies the past, present, and the future!");
				} else if (jumper == 1){
					cm.sendNextPrev("Check out the female shaman serving the Mushroom God, and I strongly recommend trying Takoyaki, Yakisoba, and other delicious food sold in the streets of Japan. Now, let's head over to #b#m800000000##k, a mythical place if there ever was one.");
				} else if (jumper == 2){
					cm.sendNextPrev("This is the only town where you'll see people floating around in boats right in the middle of the town! Alright, now let's head over to Floating Market, where the beauty of nature coexists with rich tradition!");
				}
		} else if (status == 4) {
			if(cm.getMeso() < cost[jumper]) {
				cm.sendPrev("Please check and see if you have enough mesos to go.");
			} else {
				if(section == 0) {
					cm.getChar().saveLocation(SavedLocationType.WORLDTOUR);
				}
				cm.gainMeso(-cost[jumper]);
				cm.warp(mapid[jumper]);
				cm.dispose();
			}
		}
	}
}	

